#include <iostream>
#include <memory>

#include "Udp_Server.hpp"
#include "Dict.hpp"
#include "Log.h"


// 运行：./udpserver local-port
//      ./udpserver 8888

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cout << "Usage: " << argv[0] << "local-port" << std::endl;
        exit(0);
    }

    uint16_t port = std::stoi(argv[1]);
    Enable(LOG_OUTPUT_SCREEN);

    Dict dict("./dict.txt");

    func_t translate = std::bind(&Dict::Translate, &dict, std::placeholders::_1);

    std::unique_ptr<UdpServer> ups = std::make_unique<UdpServer>(translate, port);
    ups->Init();
    ups->Start();
    return 0;
}